package com.leo.tool.jdk.jdk5;

/**
 * @author Leo
 * @date 2019/06/30
 */
public class SelfBoundedTest {

    /**
     * SelfBounded自限定泛型，限定泛型为子类，不包含自身
     * Demo in jdk : Enum.class
     */
    abstract class SelfBounded<E extends SelfBounded<E>> implements Comparable<E> {}

    /**
     * SelfBoundedA不能设置为SelfBounded
     */
    class SelfBoundedA extends SelfBounded<SelfBoundedA> {

        @Override
        public int compareTo(SelfBoundedA o) {
            return 0;
        }
    }
    
    class SelfBoundedB extends SelfBounded<SelfBoundedB> {

        @Override
        public int compareTo(SelfBoundedB o) {
            return 0;
        }
    }
    
    class SelfBoundedC extends SelfBounded<SelfBoundedC> {

        @Override
        public int compareTo(SelfBoundedC o) {
            return 0;
        }
    }
    
}